package edu.tjut.tjutcommunity.controller;


import edu.tjut.tjutcommunity.entity.Academy;
import edu.tjut.tjutcommunity.entity.Message;
import edu.tjut.tjutcommunity.entity.Pair;
import edu.tjut.tjutcommunity.service.AcademyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author yhh
 * @since 2022-04-15
 */
@RestController
@RequestMapping("/academy")
public class AcademyController {

    final
    AcademyService academyService;

    public AcademyController(AcademyService academyService) {
        this.academyService = academyService;
    }

    @GetMapping("/getAcademies")
    public Message getAcademies() {
        List<Academy> academies = academyService.getAcademies();
        if(academies==null||academies.isEmpty()) return Message.empty();
        return Message.ok(academies);
    }
}

